package cn.xianshu.quartz.service.impl;


import cn.xianshu.quartz.service.IQuartzService;
import cn.xianshu.quartz.util.QuartzUtil;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional
public class QuartzServiceImpl implements IQuartzService {

    @Autowired
    private Scheduler scheduler;

    @Override
    public void insertOrderExpireJob(String JobName, Class cls, Object params, Date excuteTime) {
        System.out.println("添加定时任务!");
        QuartzUtil.addJob(
                scheduler, // 容器
                JobName, // 定时任务名
                cls, // 工作的类
                params, // 数据
                excuteTime // 执行时间
        );
    }
}
